package org.ligson.springboot.simple;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.apache.commons.codec.digest.DigestUtils;

public class JsonMD5 {

    public static void main(String[] args) throws Exception {
        ObjectMapper objectMapper = new ObjectMapper();
        //objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
        //objectMapper.configure(SerializationConfig.)
        objectMapper.enable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setId("111111");
            user.setAge("45");
            user.setName("test" + i);
            String ast = objectMapper.writeValueAsString(user);
            String hex = DigestUtils.md5Hex(ast);
            System.out.println("hex:" + hex);
            System.out.println("json:" + ast);

        }
    }
}
